# -*- coding: utf-8 -*- 
"""
========================================================================================================================
@project : my-sanic
@file: myScheduler
@Author: mengying
@email: 652044581@qq.com
@date: 2023/3/17 11:18
@desc: 
========================================================================================================================
"""
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.schedulers.background import BackgroundScheduler

GlobalAsyncScheduler = AsyncIOScheduler()  # 全局异步定时器
GlobalSyncScheduler = BackgroundScheduler()  # //全局同步定时器


class MyScheduler:
    """定时器的基类"""

    def __init__(self, Scheduler):
        self._scheduler = Scheduler

    def get_scheduler(self):
        return self._scheduler


class MyAsyncScheduler(MyScheduler):
    """异步定时器"""

    def __init__(self):
        super(MyAsyncScheduler, self).__init__(GlobalAsyncScheduler)


class MySyncScheduler(MyScheduler):
    """同步定时器"""

    def __init__(self):
        super(MySyncScheduler, self).__init__(GlobalSyncScheduler)
